package redis

import (
	"fmt"
	"github.com/go-redis/redis"
	"srv/app_config"
)

var (
	redisClient *redis.Client
	err         error
)

func Init() {
	rc := app_config.AppConf.RedisConfig
	redisClient = redis.NewClient(&redis.Options{
		Addr:     rc.Host + ":" + rc.Port,
		Password: rc.Pwd,
		DB:       rc.DB,
	})
	_, err = redisClient.Ping().Result()
	if err != nil {
		panic(err)
	}
	fmt.Println("redis 连接成功:", redisClient)
}
